import Vue from "vue"
import Vuex from "vuex"

Vue.use(Vuex)

export default new Vuex.Store({
	state: null != window.sessionStorage.getItem('state')?JSON.parse(window.sessionStorage.getItem('state')):{
		userInfo: {
			username:''
		}
	},
	getters: {
		getUser(state){
			return state.userInfo
		}
	},
	mutations: {
		updateUser(state, userInfo){
			state.userInfo = userInfo
		}
	},
	actions: {
		asyncUpdateUser(context, userInfo){
			context.commit('updateUser', userInfo)
		}
	}
	
})
